package cn.itcast.springbootinit.controller;

import cn.itcast.springbootinit.json.Hello;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    @Value("${name}")
    private String xxx;
    @Value("${person.name}")
    private String name;
    @Value("${adress[0]}")
    private String address01;
    @Value("${msg1}")
    private String msg1;
    @Value("${msg2}")
    private String msg2;

    @Autowired
    private Environment env;

    @Autowired
    private Hello hello;

    @GetMapping("/hello")
    public String hello(){
        System.out.println(xxx);
        System.out.println(name);
        System.out.println(address01);
        System.out.println(msg1);
        System.out.println(msg2);
        System.out.println("=========");
        System.out.println(env.getProperty("name"));
        System.out.println("=========");
        System.out.println(hello);
        return "hello";
    }
}
